package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo {
    public static void main(String[] args) {
/*
        Collection c=new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("cxk");
        //[元素1.toString， 元素2.toString， ....]
        System.out.println(c);
        System.out.println(c.size());//集合的元素个数
        System.out.println(c.isEmpty());//判断集合是否为空集
        c.clear();//清空集合
        System.out.println(c);
        System.out.println(c.size());
        System.out.println(c.isEmpty());

 */
        Collection c=new ArrayList();

        c.add(new Point(2,5));
        c.add(new Point(3,8));
        c.add(new Point(4,7));
        c.add(new Point(5,6));
        c.add(new Point(3,8));
        System.out.println(c);

        Point p=new Point(3,8);
        boolean contains=c.contains(p);
        System.out.println("是否包含？"+contains);
        /*
        boolean contains(Object o):
        判断当前集合是否包含元素o
        判断依据是元素与当前集合比较equals()有没有true
         */
        c.remove(p);//删除的是内容相同的元素，且按顺序只删一次，
        System.out.println(c);
        //集合存放的是元素的引用（地址）
        Collection cc=new ArrayList();
        Point pp=new Point(1,2);
        cc.add(pp);
        System.out.println(cc);
        pp.setX(10);
        System.out.println(cc);







    }
}
